package com.zkh.myutils.net.upload;

import java.io.File;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.zkh.myutils.system.UploadConfigBean;

/**
 * 临时变量对象
 * @author zkh
 */
class Variable {
	//公共参数
	public HttpServletRequest request;
	public UploadConfigBean config;
	public boolean saveProgress;
	public long totalSize;
	
	//分界符
	public byte[] separator;
	//处理阶段。1：查找分隔符，2：查找表单类型，3：查找文件类型，4：查找表单数据或文件数据
	public int stage = 1;
	//换行符索引
	public List<Integer> rnidxList = new ArrayList<>();
	//上次未处理完的数据
	public byte[] undeals = new byte[0];
	//当前内容类型。-1：未知，1：表单，2：文件
	public int type = -1;
	//已上传文件大小
	public long uploaded = 0;
	//当前数据
	public FileItem item = null;
	public int find = -1;
	public long fileSize = 0;
	//跳过空行（在正式数据前，会有一个空行，需要跳过）
	public boolean breakEmpty = false;
	//临时文件
	public File tempFile = null;
	//临时内容（用来存上次保存内容）
	public byte[] tempContent = new byte[0];
	//文件流
	public OutputStream os = null;

	Variable(HttpServletRequest request, UploadConfigBean config, boolean saveProgress, long totalSize){
		this.request = request;
		this.config = config;
		this.saveProgress = saveProgress;
		this.totalSize = totalSize;
	}
}
